package com.gitee.qdbp.jdbc.plugins.impl;

import org.springframework.core.convert.ConversionService;
import com.gitee.qdbp.able.convert.ObjectTypeConverter;
import com.gitee.qdbp.jdbc.support.ConversionServiceAware;

/**
 * 通过Spring实现的类型转换类
 *
 * @author zhaohuihua
 * @version 20210308
 */
public class SpringTypeConverter implements ObjectTypeConverter, ConversionServiceAware {

    /** Spring的类型转换处理类 **/
    private ConversionService conversionService;

    @Override
    public <T> T convert(Object value, Class<T> clazz) {
        return conversionService.convert(value, clazz);
    }

    /** Spring的类型转换处理类 **/
    public ConversionService getConversionService() {
        return conversionService;
    }

    /** Spring的类型转换处理类 **/
    @Override
    public void setConversionService(ConversionService conversionService) {
        this.conversionService = conversionService;
    }
}
